<include file="public@mobileHeader"/>
<section class="ui-container homework">
    <div class="ui-row ui-whitespace">
        <h1>编辑作业</h1>
    </div>

    <form action="{:url('Homework/editPost')}" method="post" class="js-ajax-form">
        <input type="hidden" id="id" name="id" value="{$data.id}">
        <div class="ui-form-item ui-border-b">
            <label>老师:</label>
            <input type="text" readonly value="{$data.tname}">
        </div>

        <div class="ui-form-item ui-border-b">
            <label>班级:</label>
            <input type="text" readonly value="{$data.cname}">
        </div>

        <div class="ui-form-item ui-border-b">
            <label>
                课次:
            </label>
            <input type="number" name="progress"  value="{$data.progress}" placeholder="请输入课次">
        </div>
        <div class="ui-form-item ui-form-item-textarea ui-border-b" >
            <label>
                上课进度:
            </label>
            <textarea  id="lesson_theme" name="lesson_theme" type="text" placeholder="请输入上课进度" ></textarea>
        </div>
        <div class="ui-form-item ui-form-item-textarea ui-border-b">
            <label>
                作业内容:
            </label>
            <textarea id="content" name="content" type="text" placeholder="请输入作业内容"></textarea>
        </div>
        <div class="ui-btn-wrap">
            <button class="ui-btn-lg ui-btn-primary js-ajax-submit" type="submit">
                提交
            </button>
        </div>
    </form>
</section>
<include file="public@mobileFooter"/>
<script type="text/javascript">
    $(function () {
        $('#lesson_theme').val("{$data['lesson_theme']}");
        $('#content').val("{$data['content']}");

        $('body').on('change', '.class_id', function () {
            $id = $(this).find('option').not(function () {
                return !this.selected
            }).val();
            $_this = $(this);
            $.ajax({
                'url': "{:url('Homework/changProgress')}",
                'data': {'id': $id},
                'success': function (data) {
                    data = eval('(' + data + ')');
                    $("#progress").val(data.progress);
                    $("#progressedit").val(data.progress);
                },
                'error': function () {
                }
            })
        });

        $('body').on('change', '#teacher_id_id', function () {
            $id = $(this).find('option').not(function () {
                return !this.selected
            }).val();
            $.ajax({
                'url': "{:url('Homework/changeLesson')}",
                'data': {'id': $id},
                'success': function (data) {
                    data = eval('(' + data + ')');
                    $("#class_id_id").empty();
                    $("<option>选择班级</optioin>").appendTo($("#class_id_id"));
                    for (var i = 0; i < data.length; i++) {
                        $("<option value='" + data[i].id + "'>" + data[i].name + "</optioin>").appendTo($("#class_id_id"));
                    }
                },
                'error': function () {
                }
            })
        });
    });

</script>

